###FIRST RUN Study 2 Data Code.R###

####APPENDIX TABLE 7####
atable7 <- matrix(NA,11,6)

#TAXES
atable7[1,1:3] <- as.vector(unlist(t.test(study2_ca$MALE[!is.na(study2_ca$PROP30_SQ) & study2_ca$PROP30_TREAT==1],study2_ca$MALE[!is.na(study2_ca$PROP30_SQ) & study2_ca$PROP30_TREAT==0])[c(5,3)]))
atable7[2,1:3] <- as.vector(unlist(t.test(study2_ca$AGE[!is.na(study2_ca$PROP30_SQ) & study2_ca$PROP30_TREAT==1],study2_ca$AGE[!is.na(study2_ca$PROP30_SQ) & study2_ca$PROP30_TREAT==0])[c(5,3)]))
atable7[3,1:3] <- as.vector(unlist(t.test(study2_ca$EDUCATION[!is.na(study2_ca$PROP30_SQ) & study2_ca$PROP30_TREAT==1],study2_ca$EDUCATION[!is.na(study2_ca$PROP30_SQ) & study2_ca$PROP30_TREAT==0])[c(5,3)]))
atable7[4,1:3] <- as.vector(unlist(t.test(study2_ca$INCOME[!is.na(study2_ca$PROP30_SQ) & study2_ca$PROP30_TREAT==1],study2_ca$INCOME[!is.na(study2_ca$PROP30_SQ) & study2_ca$PROP30_TREAT==0])[c(5,3)]))
atable7[5,1:3] <- as.vector(unlist(t.test(study2_ca$LIBCON[!is.na(study2_ca$PROP30_SQ) & study2_ca$PROP30_TREAT==1],study2_ca$LIBCON[!is.na(study2_ca$PROP30_SQ) & study2_ca$PROP30_TREAT==0])[c(5,3)]))
atable7[6,1:3] <- as.vector(unlist(t.test(study2_ca$RISK[!is.na(study2_ca$PROP30_SQ) & study2_ca$PROP30_TREAT==1],study2_ca$RISK[!is.na(study2_ca$PROP30_SQ) & study2_ca$PROP30_TREAT==0])[c(5,3)]))
atable7[7,1:3] <- as.vector(unlist(t.test(study2_ca$INFORMED30[!is.na(study2_ca$PROP30_SQ) & study2_ca$PROP30_TREAT==1],study2_ca$INFORMED30[!is.na(study2_ca$PROP30_SQ) & study2_ca$PROP30_TREAT==0])[c(5,3)]))
atable7[8,1:3] <- as.vector(unlist(t.test(study2_ca$IMPORT30[!is.na(study2_ca$PROP30_SQ) & study2_ca$PROP30_TREAT==1],study2_ca$IMPORT30[!is.na(study2_ca$PROP30_SQ) & study2_ca$PROP30_TREAT==0])[c(5,3)]))
atable7[9,1:3] <- as.vector(unlist(t.test(study2_ca$BLACK[!is.na(study2_ca$PROP30_SQ) & study2_ca$PROP30_TREAT==1],study2_ca$BLACK[!is.na(study2_ca$PROP30_SQ) & study2_ca$PROP30_TREAT==0])[c(5,3)]))
atable7[10,1:3] <- as.vector(unlist(t.test(study2_ca$HISP[!is.na(study2_ca$PROP30_SQ) & study2_ca$PROP30_TREAT==1],study2_ca$HISP[!is.na(study2_ca$PROP30_SQ) & study2_ca$PROP30_TREAT==0])[c(5,3)]))
atable7[11,1:3] <- as.vector(unlist(t.test(study2_ca$WHITE[!is.na(study2_ca$PROP30_SQ) & study2_ca$PROP30_TREAT==1],study2_ca$WHITE[!is.na(study2_ca$PROP30_SQ) & study2_ca$PROP30_TREAT==0])[c(5,3)]))

#DEATH PENALTY
########################
atable7[1,4:6] <- as.vector(unlist(t.test(study2_ca$MALE[!is.na(study2_ca$PROP34_SQ) & study2_ca$PROP34_TREAT==1],study2_ca$MALE[!is.na(study2_ca$PROP34_SQ) & study2_ca$PROP34_TREAT==0])[c(5,3)]))
atable7[2,4:6] <- as.vector(unlist(t.test(study2_ca$AGE[!is.na(study2_ca$PROP34_SQ) & study2_ca$PROP34_TREAT==1],study2_ca$AGE[!is.na(study2_ca$PROP34_SQ) & study2_ca$PROP34_TREAT==0])[c(5,3)]))
atable7[3,4:6] <- as.vector(unlist(t.test(study2_ca$EDUCATION[!is.na(study2_ca$PROP34_SQ) & study2_ca$PROP34_TREAT==1],study2_ca$EDUCATION[!is.na(study2_ca$PROP34_SQ) & study2_ca$PROP34_TREAT==0])[c(5,3)]))
atable7[4,4:6] <- as.vector(unlist(t.test(study2_ca$INCOME[!is.na(study2_ca$PROP34_SQ) & study2_ca$PROP34_TREAT==1],study2_ca$INCOME[!is.na(study2_ca$PROP34_SQ) & study2_ca$PROP34_TREAT==0])[c(5,3)]))
atable7[5,4:6] <- as.vector(unlist(t.test(study2_ca$LIBCON[!is.na(study2_ca$PROP34_SQ) & study2_ca$PROP34_TREAT==1],study2_ca$LIBCON[!is.na(study2_ca$PROP34_SQ) & study2_ca$PROP34_TREAT==0])[c(5,3)]))
atable7[6,4:6] <- as.vector(unlist(t.test(study2_ca$RISK[!is.na(study2_ca$PROP34_SQ) & study2_ca$PROP34_TREAT==1],study2_ca$RISK[!is.na(study2_ca$PROP34_SQ) & study2_ca$PROP34_TREAT==0])[c(5,3)]))
atable7[7,4:6] <- as.vector(unlist(t.test(study2_ca$INFORMED34[!is.na(study2_ca$PROP34_SQ) & study2_ca$PROP34_TREAT==1],study2_ca$INFORMED34[!is.na(study2_ca$PROP34_SQ) & study2_ca$PROP34_TREAT==0])[c(5,3)]))
atable7[8,4:6] <- as.vector(unlist(t.test(study2_ca$IMPORT34[!is.na(study2_ca$PROP34_SQ) & study2_ca$PROP34_TREAT==1],study2_ca$IMPORT34[!is.na(study2_ca$PROP34_SQ) & study2_ca$PROP34_TREAT==0])[c(5,3)]))
atable7[9,4:6] <- as.vector(unlist(t.test(study2_ca$BLACK[!is.na(study2_ca$PROP34_SQ) & study2_ca$PROP34_TREAT==1],study2_ca$BLACK[!is.na(study2_ca$PROP34_SQ) & study2_ca$PROP34_TREAT==0])[c(5,3)]))
atable7[10,4:6] <- as.vector(unlist(t.test(study2_ca$HISP[!is.na(study2_ca$PROP34_SQ) & study2_ca$PROP34_TREAT==1],study2_ca$HISP[!is.na(study2_ca$PROP34_SQ) & study2_ca$PROP34_TREAT==0])[c(5,3)]))
atable7[11,4:6] <- as.vector(unlist(t.test(study2_ca$WHITE[!is.na(study2_ca$PROP34_SQ) & study2_ca$PROP34_TREAT==1],study2_ca$WHITE[!is.na(study2_ca$PROP34_SQ) & study2_ca$PROP34_TREAT==0])[c(5,3)]))
########################
